#include "widget_helper_win32.h"
#include "widget.h"
#include <windows.h>
#include <iostream>

using namespace krryn::gui;

char * widget_helper_win32::window_class(){
	static bool m_IsRegistered = false;

	if(!m_IsRegistered){
		WNDCLASS l_WindowClass;
		memset(&l_WindowClass, 0, sizeof(l_WindowClass));

		l_WindowClass.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
		l_WindowClass.lpfnWndProc	= (WNDPROC)::DefWindowProc;
		l_WindowClass.hIcon			= LoadIcon(NULL, IDI_WINLOGO);
		l_WindowClass.hCursor		= LoadCursor(NULL, IDC_ARROW);
		l_WindowClass.hbrBackground	= (HBRUSH) COLOR_BACKGROUND;
		l_WindowClass.lpszClassName	= "krryn::window_class";

		if(!RegisterClass(&l_WindowClass)){
			throw widget_exception("Can't register window class");
		}else{
			m_IsRegistered = true;
		}
	}

	return "krryn::window_class";
}
